package org.example.deadletter;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import org.example.utils.RabbitMqUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zfj
 * @date 2022/4/24 -20:45
 * 死信队列
 * 消费者1
 */
public class Consumer02 {
	//声明死信队列
	private static final String DEAD_QUEUE = "dead-queue";

	public static void main(String[] args) throws Exception {
		Channel channel = RabbitMqUtils.getChannel();

		System.out.println("等待接收消息.....");
		DeliverCallback deliverCallback=(consumerTag,message)->{
			System.out.println("Consumer02接收的消息是："+new String(message.getBody(),"UTF-8"));
		};

		channel.basicConsume(DEAD_QUEUE,true,deliverCallback,consumerTag->{});

	}
}
